#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include "seqlist.h"

void test(seqlist_t *lista,int n){
    for(int i = 0;i < n;i++){
        InsertIntoSeqlist(lista, i, i);
    }
}

void test_ClearSeqList(seqlist_t  *p){
    if(0 <= p->last && p->last <= MAX_ARRAY_SIZE-1){
        if(p->last==-1){
            printf("顺序表为空\n");
            return ;
        }
        for(int i=0;i<=p->last;i++){
            // printf("%d ",p->data[i]);
        }
            // printf(" 有%d个有效元素\n",p->last+1);
    }
    return;
}

int main(void){
// 创建一个空表
    seqlist_t* list = CreateEpSeqlist();
    if(list  == NULL){
        printf("分配错误\n");
        return -1;
    } 
//插入
    clock_t begin,end;
    begin=clock();
    test(list,1000);
    end=clock();
    printf("插入1千个用时%lf(s)\n",(double)(end-begin)/CLOCKS_PER_SEC);

//索引
    begin=clock();
    test_ClearSeqList(list);
    end=clock();
    printf("索引1千个用时%lf(s)\n",(double)(end-begin)/CLOCKS_PER_SEC);
// 清空表
    ClearSeqList(list);


//插入
    // clock_t begin,end;
    begin=clock();
    test(list,10000);
    end=clock();
    printf("插入1万个用时%lf(s)\n",(double)(end-begin)/CLOCKS_PER_SEC);
//索引
    begin=clock();
    test_ClearSeqList(list);
    end=clock();
    printf("索引1万个用时%lf(s)\n",(double)(end-begin)/CLOCKS_PER_SEC);
// 清空表
    ClearSeqList(list);

    
//插入
    // clock_t begin,end;
    begin=clock();
    test(list,100000);
    end=clock();
    printf("插入10万个用时%lf(s)\n",(double)(end-begin)/CLOCKS_PER_SEC);
//索引
    begin=clock();
    test_ClearSeqList(list);
    end=clock();
    printf("索引10万个用时%lf(s)\n",(double)(end-begin)/CLOCKS_PER_SEC);
// 清空表
    ClearSeqList(list);
    free(list);
    list=NULL;
    return 0;
}